const router = require("@koa/router")()
const mongo = require("../../model/api/Material ")
const { localTime } = require("../../utils/index");


router.get("/", async (ctx) => {
  const limit = Number(ctx.query.limit) || 10;
  const skip = Number(ctx.query.page) * limit || 0
  try {
    const res = await mongo.find({}, null, { limit, skip })
    console.log(res)
    ctx.body = {
      status: 0,
      message: "success",
      data: res
    }
  } catch (error) {
    console.log(error);
    ctx.body = {
      status: -1,
      message: error.message,
      data: null
    }
  }
})

module.exports = router